<script lang="ts" setup>
import { OrderApi } from '@/apis'
import { Message } from '@arco-design/web-vue'

const emits = defineEmits(['change'])

const visible = ref<boolean>(false)
const modal = ref<string >('')
const orderId = ref<string>('')

const open = (id: string) => {
  orderId.value = id
  visible.value = true
}

const beforeOk = async () => {
  if (!modal.value) {
    return false
  }
  await OrderApi.updateEndValidTime({ orderId: orderId.value, endValidTime: modal.value })
  Message.success('修改过期时间成功')
  emits('change')
  return true
}

defineExpose({
  open,
})
</script>

<template>
  <a-modal v-model:visible="visible" title="修改过期时间" @before-ok="beforeOk">
    <a-date-picker
      v-model="modal"
      class="w-full"
      show-time
      :time-picker-props="{ defaultValue: '00:00:00' }"
      format="YYYY-MM-DD HH:mm:ss"
      placeholder="请选择过期时间"
    />
  </a-modal>
</template>

<style lang='less' scoped>
</style>
